package com.neusoft.care.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.care.po.CareItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CareItemDao extends BaseMapper<CareItem> {
    // 在这里可以定义一些自定义的SQL操作（如果有需要）
//    自定义查询
    @Select("<script>" +
            "SELECT item_id, item_name, price, status, cycle, times, description " +
            "FROM care_items " +
            "WHERE (is_active IS NULL OR is_active != '移除') " + // 添加默认条件
            "<if test='itemName != null and itemName != \"\"'>" +
            "  AND item_name LIKE CONCAT('%', #{itemName}, '%') " +
            "</if> " +
            "<if test='status != null and status != \"\"'>" +
            "  AND status = #{status} " +
            "</if> " +
            "</script>")
    List<CareItem> getCareItemsByConditions(@Param("itemName") String itemName, @Param("status") String status);
}